/**
 * CS1332 Ashwin Ram Spring 2010
 * HW2 BSTNode.java
 * Cesar Gonzalez-Flores
 * 
 * Collaboration Statement
 * "I worked on the homework assignment alone, using only course materials."
 * 
 * Class Description
 * This class represents a simple generic node to be used in a binary tree
 */

public class BSTNode<K extends Comparable<K>> implements BinaryNode<K>{
	protected K data;
	protected BinaryNode<K> left,right, parent;
	protected boolean duplicate;
	
	public BSTNode(){
		data=null;left=null;right=null;parent=null;
	}//end constructor
	
	public BSTNode(K data, boolean dup){
		this.data=data; duplicate = dup; left=null;right=null; parent=null;
	}//end constructor
	
	public BSTNode(K data, BinaryNode<K> left,BinaryNode<K> right){
		this.data=data;
		this.left=left;
		this.right=right;
	}//end constructor
	/**
	 * Returns the data held by this node.  Returns NULL for empty nodes.
	 * @return data held here or null
	 */
	public K getData(){return data;}
	
	/**
	 * Sets the data held by this node.
	 * @param newValue the new value of this node
	 */
	public void setData(K newValue){data=newValue;}
	
	/**
	 * Is this an "empty" node?
	 * @return true if yes, no if no
	 */
	public boolean isEmptyNode(){if(data==null)return true; else return false;}
	
	/**
	 * Returns the left child of this node or null if there is not one.
	 * @return a BinaryNode or null
	 */
	public BinaryNode<K> getLeftChild(){return left;}
	
	/**
	 * Sets the left child.  Can be null for no left child.
	 * @param newLeftChild a BinaryNode or null
	 */
	public void setLeftChild(BinaryNode<K> newLeftChild){left=newLeftChild;}
	
	/**
	 * Returns the right child of this node or null if there is not one.
	 * @return a BinaryNode or null
	 */
	public BinaryNode<K> getRightChild(){return right;}
	
	/**
	 * Sets the right child.  Can be null for no right child.
	 * @param newRightChild a BinaryNode or null
	 */
	public void setRightChild(BinaryNode<K> newRightChild){right=newRightChild;}
	
	public BinaryNode<K> getParent(){return parent;}
	
	public void setParent(BinaryNode<K> newParent){parent = newParent;}
	
	public boolean getDuplicate()
	{
		return duplicate;
	}
	
	public void setDuplicate(boolean dup)
	{
		duplicate = dup;
	}
}